package com.mxdx.edu.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.mxdx.edu.dao.FamilyMembeInfoDao;
import com.mxdx.edu.model.FamilyMembeInfo;
import com.mxdx.edu.service.IFamilyMembeInfoService;

@Service
public class FamilyMembeInfoService implements IFamilyMembeInfoService {

	@Resource
	private FamilyMembeInfoDao familyMembeInfoDao;

	@Override
	public boolean save(FamilyMembeInfo familyMembeInfo) {
		return familyMembeInfoDao.save(familyMembeInfo) > 0;
	}

	@Override
	public List<FamilyMembeInfo> selectFamilyMembeInfo(Map<String, Object> map) {
		List<Map<String, Object>> listMap = familyMembeInfoDao
				.findListByMap(map);
		List<FamilyMembeInfo> list = new ArrayList<>();
		for (Map<String, Object> temp : listMap) {
			JSONObject json = (JSONObject) JSONObject.toJSON(temp);
			list.add(JSONObject.toJavaObject(json, FamilyMembeInfo.class));
		}
		return list;
	}

	@Override
	public boolean mergeFamilyMembeInfo(Map<String, Object> map) {
		return familyMembeInfoDao.updateByMap(map) > 0;
	}

	@Override
	public List<Map<String, Object>> findFamilyMembeInfo(Map<String, Object> map) {
		return familyMembeInfoDao.findListByMap(map);
	}

}
